﻿using System.Windows;
using System.Windows.Input;

namespace Silvery.Scene
{
    /// <summary>
    /// 场景类
    /// </summary>
    public class NScene : SceneLogic, IScene
    {
        /// <summary>
        /// 构造
        /// </summary>
        public NScene()
        {
            base.MouseLeftButtonUp += new MouseButtonEventHandler(NScene_MouseLeftButtonUp);
        }

        void NScene_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            base.GotoHere(e.GetPosition(this));
        }
        protected override void OnLeave()
        {
            base.OnLeave();
        }
        /// <summary>
        /// 进入场景，以元素方式
        /// </summary>
        /// <param name="sceneElement"></param>
        /// <param name="async"></param>
        public void SceneEnter(FrameworkElement sceneElement, bool async = true)
        {
            OnEnter(sceneElement, async);
        }
        /// <summary>
        /// 进入指定场景，以xaml读取方式
        /// </summary>
        /// <param name="xamldata"></param>
        public void SceneEnter(string xamldata)
        {
            OnEnter(xamldata);
        }
        /// <summary>
        /// 刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="timer"></param>
        public override void OnUpdata(BaseObject sender, ITimer timer)
        {
            if (SceneElement is ISceneElement)
                (SceneElement as ISceneElement).OnUpdata(this, timer);
            base.OnUpdata(sender, timer);
        }
    }
}
